package com.fare.taluo.application.impl.queue;

import java.util.ArrayList;
import java.util.List;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.dayatang.domain.Entity;
import com.fare.taluo.application.queue.QueueEmailGetRegisterCodeApplication;
import com.fare.taluo.core.domain.queue.QueueBaseEntity;
import com.fare.taluo.core.domain.queue.message.QueueRegisterEmailInfoEntity;
import com.fare.taluo.util.DateUtils;
import com.fare.taluo.vo.queue.QueueRegisterEmailInfoVO;

@Transactional
@Scope("singleton")
@Service("queueEmailGetRegisterCodeApplication")
public class QueueEmailGetRegisterCodeApplicationImpl extends
		ScheduleQueueApplicationImpl<QueueRegisterEmailInfoVO> implements
		QueueEmailGetRegisterCodeApplication {

	/*@Override
	public boolean archive(QueueRegisterEmailInfoVO vo) throws Exception {
		// TODO Auto-generated method stub
		return false;
	}*/

	@Override
	protected QueueBaseEntity<? extends Entity> newInstance() throws Exception {
		return new QueueRegisterEmailInfoEntity();
	}
	
	public static List<QueueRegisterEmailInfoVO> explanationQueueEmailMessageEntity(List<QueueRegisterEmailInfoEntity> listEntity){
		List<QueueRegisterEmailInfoVO> listVo=new ArrayList<QueueRegisterEmailInfoVO>();
		if(listEntity.size()>0){
			for(QueueRegisterEmailInfoEntity entity:listEntity){
				QueueRegisterEmailInfoVO vo =new QueueRegisterEmailInfoVO();
				if(entity.getBody() !=null && entity.getSubject() !=null && entity.getCreateTime()!=null){
					vo.setBody(entity.getBody());
					vo.setCreateTime(entity.getCreateTime());
					vo.setCreateTimeStr(DateUtils.dateToStr(entity.getCreateTime(),"yyyy-MM-dd"));
					vo.setEndTime(entity.getEndTime());
					vo.setId(entity.getId());
					vo.setName(entity.getName());
					vo.setPlanStartTime(entity.getPlanStartTime());
					vo.setToAddress(entity.getToAddress());
					vo.setSubject(entity.getSubject());
					vo.setStatus(entity.getStatus());
					vo.setStartTime(entity.getStartTime());
					vo.setSpentTimes(entity.getSpentTimes());
					vo.setStatusStr(entity.getStatus()+"");
					listVo.add(vo);
				}
			}
		}
		return listVo;
	}

	
}
